#include<iostream>
#include<vector>
using namespace std;
class Solution0 {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        int left=0,right=numbers.size()-1;
        while(left<right)
        {
            int mid=right+left>>1;
            if(left!=mid&&numbers[left]+numbers[mid]>=target)right=mid;
            else if(right!=mid&&numbers[right]+numbers[mid]<=target)left=mid;
            if(left<right&&numbers[left]+numbers[right]<target)left++;
            if(left<right&&numbers[left]+numbers[right]>target)right--;
            if(numbers[left]+numbers[right]==target)break;
        }
        if(left<right)return {left+1,right+1};
        else return {};
    }
};

class Solution1 {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        int left=0,right=numbers.size()-1;
        while(left<right)
        {
            while(left<right&&numbers[left]+numbers[right]<target)left++;
            while(left<right&&numbers[left]+numbers[right]>target)right--;
            if(numbers[left]+numbers[right]==target)break;
        }
        if(left<right)return {left+1,right+1};
        else return {};
    }
};